﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Messaging;
using System.Net;
using System.Text;
using System.Transactions;

namespace Receiver
{
    class Program
    {
        static void Main(string[] args)
        {
            var queueName = @".\private$\lpiqueue";
            try
            {
                if (!MessageQueue.Exists(queueName))
                {
                    MessageQueue.Create(queueName);
                    Console.WriteLine("创建队列成功");
                }

                var queue = new MessageQueue(queueName);
                queue.Formatter = new BinaryMessageFormatter();
                while (true)
                {
                    var message = queue.Receive();
                    var body = (byte[])message.Body;
                    Console.WriteLine(body.Length);
                }


            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            Console.ReadLine();
        }
    }
}
